home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4926 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What does the -O option do???!!!
  5. Date: 11 Feb 1996 11:59:45 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4flhrhINNtj@keats.ugrad.cs.ubc.ca>
  8. References: <4ehger$cj9@mark.ucdavis.edu> <823827008snz@genesis.demon.co.uk> <4fiphrINNrvr@keats.ugrad.cs.ubc.ca> <9602102332.AA09466@dxmint.cern.ch>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <9602102332.AA09466@dxmint.cern.ch>,
  12. Dan Pop  <danpop@mail.cern.ch> wrote:
  13. >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  14. >
  15. >>... as long as it is not hard-coded to treat identifiers like "free" specially. 
  16. >
  17. >A compiler is free to treat identifiers like "free" specially after the
  18. >relevant header has been included.
  19. >
  20. >>If you write your own free() with different semantics, you would not want the
  21. >>compiler messing with that. 
  22. >
  23. >If you write your own free() you invoke undefined behaviour and you can't
  24. >expect the compiler to behave in a sensible way.  The implementation 
  25. >namespace is a big taboo in C.
  26.  
  27. Are you serious? What if I'm writing a little embedded kernel that doesn't use
  28. anything resembling the standard C library, and I use free() for something
  29. quite different?
  30.  
  31. This is truly silly. The standard may say one thing, but it's despicable to
  32. actually implement a compiler that treats free() specially. There is nothing in
  33. the semantics of free() that requires special treatment in order to do its job.
  34.  
  35. For one thing, malloc() is far from a perfect allocation scheme, so why give it
  36. preferential treatment? I might design my own library which uses allocation
  37. handles, and performs heap compaction, for instance.
  38.  
  39. >>It's just another function, after all.
  40. >
  41. >No, it isn't.  Have a look at the standard.
  42.  
  43. I just had a look at the sources for my standard library. It sure looks like a
  44. function to me. (Walks like a duck, quacks like a duck, ... )
  45.  
  46. I wonder whether the seats of that ANSI commitee were actually populated by
  47. programmers.
  48. -- 
  49.  
  50.